import subprocess
import os

# 获取当前目录
current_dir = os.path.dirname(os.path.abspath(__file__))

# 设置脚本路径
script_path = os.path.join(current_dir, 'test1.sh')  # 这里确保路径正确
print(script_path)
try:
    # 使用 subprocess 执行脚本
    result = subprocess.run(['sh', script_path], capture_output=True, text=True, check=True)

    # 打印脚本的标准输出
    print(result.stdout)

except subprocess.CalledProcessError as e:
    # 捕获并打印错误信息
    print(f"Error occurred: {e.stderr}")

except Exception as e:
    # 捕获其他
    print(f"Error occurred: {str(e)}")
    pass